<?php
	class Head{
		private $title="";
		private $code="";
		
		public function __construct(){
			$this->title = "";
			$this->code = "<meta http-equiv='X-UA-Compatible' content='IE=edge'/>
						   <meta name='author' content='Nuno Pombo'/>
						   <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'/>
					       <link href='images/favicon.png' rel='shortcut icon'/>";
		}
		
		public function addLayout($filePath){
			$this->code = $this->code . "<link rel='stylesheet' type='text/css' href='". $filePath . "'/>";
		}
		
		public function addTitle($title){
			$this->code = $this->code . "<title>" . $title . "</title>"; 
		}
		
		public function printHead(){
			$this->code = "<head>" . $this->code . "</head>";
			echo $this->code;
		}
	}
	
	class LeftPage{
		private $code="";
		
		public function __construct(){
			$this->code = "";
		}
		
		public function addMenuTitle($title){
			$this->code = $this->code . "<div class='menuTitle'>" . $title . "</div>";
		}
		
		public function addLoginForm($action, $method){
			$this->code = $this->code . "<table class='login'>
											<form action='" . $action . "' method='" . $method . "'>
												<tr>
													<td><input class='input' type='text' align='center' name='user'/></td>
												</tr>
												<tr>
													<td><input class='input' type='password' align='center' name='pass'/></td>
												</tr>
												<tr>
													<td>
														<input class='button' type='submit' value='Login' align='right'/>
														<a href='signup.php'>Registar</a>
													</td>
												</tr>
											</form>
										</table>";
		}
		
		public function addLogoutButton(){
			$this->code = $this->code . "<div class='login'>
											<a href='logout.php'>
												<div class='button'>Logout</div>
											</a>
										</div>";
		}
		
		public function addText($text){
			$this->code = $this->code . "<div class='menu'>" . $text . "</div>";
		}
		
		public function addElement($element){
			$this->code = $this->code . $element->getCode();
		}
		
		public function printLeftPage(){
			$this->code = "<div id='leftPage'>" . $this->code . "</div>";
			echo $this->code;
		}
	}
	
	class Content{
		private $code = "";
		
		public function __construct(){
			$this->code = "";
		}
		
		public function addSectionTitle($title){
			$this->code = $this->code . "<div class='seccaoTitle'>" . $title . "</div>";
		}
		
		public function addElement($element){
			$this->code = $this->code . $element->getCode();
		}
		
		public function addImage($src, $width, $height, $align){
			$this->code = $this->code . "<div align='" . $align . "'><img src='" . $src . "' width='" . $width . "' height='" . $height . "'/></div>";
		}

		public function addText($text, $style, $align){
			$this->code = $this->code . "<" . $style . " align='" . $align . "'>" . $text . "</" . $style . ">";
		}
		
		public function printContent(){
			$this->code = "<div id='content'>" . $this->code . "</div>";
			echo $this->code;
		}
	}
	
	class Form{
		private $code = "";
		private $auxCode = "";
		
		public function getCode(){
			$this->code = "<table class='formTable' align='center'>" . $this->code . "</table>";
			return $this->code;
		}
		
		public function linkForm($action, $method){
			$this->code = "<form action='" . $action . "' method='" . $method . "'>" . $this->code . "</form>";
		}
		
		public function addTextBox($label, $name){
			$this->code = $this->code . "<tr>
											<td>" . $label . "</td>
											<td><input class='input' type='text' align='center' name='" . $name . "'/></td>
										</tr>";
		}
		
		public function addPasswordBox($label, $name){
			$this->code = $this->code . "<tr>
											<td>" . $label . "</td>
											<td><input class='input' type='password' align='center' name='" . $name . "'/></td>
										</tr>";
		}
		
		public function addRadioOption($label, $name, $value){
			$this->auxCode = $this->auxCode . "<input class='radio' type='radio' name='" . $name . "' value='" . $value . "'/>" . $label . "</br>";
		}
		
		public function addOptions($label){
			$this->code = $this->code . "<tr>
											<td>" . $label . "</td>
											<td>" . $this->auxCode . "</td>
										</tr>";
			$this->auxCode = "";
		}
		
		public function addSelectionOption($label, $value, $selected){
			if($selected){
				$this->auxCode = $this->auxCode . "<option selected='' value='" . $value . "'>" . $label . "</option>";
			}else{
				$this->auxCode = $this->auxCode . "<option value='" . $value . "'>" . $label . "</option>";
			}
		}
		
		public function linkSelectionOptions($name){
			$this->auxCode = "<select name='" . $name . "'>" . $this->auxCode . "</select>";
		}
		
		public function addButton($value){
			$this->code = $this->code . "<tr>
											<td></td>
											<td align='right'>
												<input class='button' type='submit' value='" . $value . "' align='right'/>
											</td>
										</tr>";
		}
	}

	class ListOfLinks{
		private $code="";
		
		public function getCode(){
			$this->code = "<ul class='menuWrapper'>" . $this->code . "</ul>";
			return $this->code;
		}
		
		public function addLink($label, $url){
			$this->code = $this->code . "<a class='menuEntry' href='" . $url . "'>
											<li>" . $label . "</li>
										</a>";
		}
	}
	
	class Table{
		private $code="";
		private $auxCode="";
		
		public function getCode(){
			$this->code = "<table>" . $this->code . "</table>";
			return $this->code;
		}
		
		public function addCell($text){
			$this->auxCode = $this->auxCode . "<td>" . $text . "</td>";
		}
		
		public function addCellsToRow(){
			$this->code = $this->code . "<tr>" . $this->auxCode . "</tr>";
			$this->auxCode = "";
		}
	}
?>